package exchange;

import java.util.HashSet;
import java.util.LinkedList;

import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;

public class ItemList {
	private LinkedList<Item> items = new LinkedList<Item>();
	
	public ItemList(Item... itemsToAdd) {
		for(Item item : itemsToAdd) {
			items.add(item);
		}
	}
	
	public boolean addItem(Item item) {
		return items.add(item);
	}
	
	public boolean removeItem(Item item) {
		return items.remove(item);
	}
	
	public Item getItem(String itemName) {
		for (Item item : items) {
			if (item.getName().toLowerCase().equals(itemName.toLowerCase())) {
				return item;
			}
		}
		return new Item("dirt", new ItemStack(Material.DIRT), 0, 0);
	}
	
	public LinkedList<Item> getItems() {
		return items;
	}
	
	public String[] getItemNames() {
		HashSet<String> itemNames = new HashSet<String>();
		for(Item item : items) {
			itemNames.add(item.getName());
		}
		return itemNames.toArray(new String[0]);
	}
}
